package net.randomice.emf.observables.demo.extlibrary.observables;

import net.randomice.emf.observables.demo.extlibrary.Addressable;
import net.randomice.emf.observables.demo.extlibrary.ExtlibraryPackage;
import net.randomice.emf.observables.demo.extlibrary.Library;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;

/**
 * An Observable list wrapper for {@link Library}
 * @generated
 */
public class LibraryOS {
	public final IObservableSet o;

	public LibraryOS(IObservableSet observableSet) {
		Object type = observableSet.getElementType();
		if (type instanceof EReference) {
			type = ((EReference) type).getEType().getInstanceClass();
		}
		Assert.isTrue(null == type || Library.class.equals(type));
		o = observableSet;
	}

	public IObservableMap getMapFeature(EStructuralFeature feature) {
		if (ExtlibraryPackage.Literals.ADDRESSABLE__ADDRESS.equals(feature)) {
			return getAddress();
		}
		if (ExtlibraryPackage.Literals.LIBRARY__NAME.equals(feature)) {
			return getName();
		}
		if (ExtlibraryPackage.Literals.LIBRARY__PARENT_BRANCH.equals(feature)) {
			return getParentBranch().o;
		}
		throw new UnsupportedOperationException("Feature " + feature
				+ " not supported!");
	}

	// features from type Addressable

	private IObservableMap address = null;
	public IObservableMap getAddress() {
		if (null == address) {
			address = EMFObservables.observeMap(o,
					ExtlibraryPackage.Literals.ADDRESSABLE__ADDRESS);
		}
		return address;
	}

	// features from type Library

	private IObservableMap name = null;
	public IObservableMap getName() {
		if (null == name) {
			name = EMFObservables.observeMap(o,
					ExtlibraryPackage.Literals.LIBRARY__NAME);
		}
		return name;
	}

	// ??? many feature in set

	// ??? many feature in set

	// ??? many feature in set

	// ??? many feature in set

	private LibraryOM<Library> parentBranch = null;
	public LibraryOM<Library> getParentBranch() {
		if (null == parentBranch) {
			parentBranch = new LibraryOM<Library>(Library.class, EMFObservables
					.observeMap(o,
							ExtlibraryPackage.Literals.LIBRARY__PARENT_BRANCH));
		}
		return parentBranch;
	}

	// ??? many feature in set

	// ??? many feature in set

}
